import {Navigate, useRoutes} from "react-router-dom";
import Home from "../components/Home";
import AuthComponent from "../components/AuthComponent";
import NewsList from "../components/NewsList";
import GoodsList from "../components/GoodsList";
import My from "../components/My";
import Two from "../components/Two";
import React from "react";

const routes =[
    {
        path: "/",
        element: <Home/>
    }, {
        path: "/newsList",
        element: <AuthComponent><NewsList/></AuthComponent>
    },
    {
        path: "/goodsList",
        element: <AuthComponent><GoodsList/></AuthComponent>
    },
    {
        path: "/my",
        element: <AuthComponent><My/></AuthComponent>,
        children: [
            {
                index: true,
                element: <Navigate to={"/my/one"}/>
            },{
                path:"/my/one",
                element:<div>one页面</div>
            },{
                path:"/my/two/:id/:type.html",
                element:<Two/>
            }
        ]
    },{
        path:"/home",
        element:<Navigate to={"/"}/>
    },{
        path:"*",
        element:<div>404</div>
    }
]

export default function(){
    return useRoutes(routes);
}